$TITLE ('GET RUNNING TASK ID FUNCTION CALL')
$SYMBOLS
$NOXREF
$NOCOND
$NOMOD51
$NORB
$PAGELENGTH(80) PAGEWIDTH(110)
;************************************************************************
;*									*
;*    R T X - 5 1  :   GET RUNNING TASK ID FUNCTION CALL                *
;*							     		*
;*----------------------------------------------------------------------*
;*                                                                      *
;*    Filename     :   RTXRUNID.A51                                     *
;*    Language     :   Keil A-51                                        *
;*    Dev. system  :   Keil uVision2                                    *
;*    Targetsystem :   Any system based upon 8051 up                    *
;*                                                                      *
;*    Purpose      :   Implements the os_running_task_id function-      *
;*                     call                                             *
;*								     	*
;*----------------------------------------------------------------------*
;* Rev. |  Released   | Programmer    | Comments                        *
;*----------------------------------------------------------------------*
;* 0.1  |  10.10.1991 | Th. Fischler  | Module creation                 *
;* 5.00 | 20.10.1994  | E. Glatz      | Release 5.00                    *
;* 7.00 | 13.11.2001  | T. Mueller    | Release 7.00                    *
;************************************************************************
;*    Copyright 1991 .. 2001 METTLER  &  FUCHS  AG,  CH-8953 Dietikon   *
;************************************************************************


$INCLUDE (RTXDEBUG.INC)
$INCLUDE (RTXIMASK.INC)


;*----------------------------------------------------------------------*
;*	I M P O R T S
;*----------------------------------------------------------------------*

$INCLUDE (RTXCONST.INC)
$INCLUDE (RTXEXTRN.INC)

;*----------------------------------------------------------------------*
;*	E X P O R T S
;*----------------------------------------------------------------------*

PUBLIC  os_running_task_id


;*----------------------------------------------------------------------*
;*	P R O C E D U R E S
;*----------------------------------------------------------------------*

;*----------------------------------------------------------------------*
;*      O S _ R U N N I N G _ T A S K _ I D
;*----------------------------------------------------------------------*
;*      Get the task-number of the running task
;*----------------------------------------------------------------------*
;*      Input:  --
;*      -----
;*
;*      Output: - R7: External task-number of the running task (0..255)
;*      ------
;*
;*----------------------------------------------------------------------*

?RTX?os_running_task_id?RTXRUNID   SEGMENT CODE
                                   RSEG ?RTX?os_running_task_id?RTXRUNID

os_running_task_id:
               DBG_SYS_ENTRY
               RTX_EXCLUDE_INT
               SETB  ?RTX_SUPERVISOR_MODE            ; Supervisor_mode := on

               MOV   A, ?RTX_RUNNING_TID
               ANL   A, #1FH                         ; A = internal task_num
               MOV   DPH, #HIGH(?RTX_INTERNAL_NUM_TABLE)
               ADD   A, #LOW(?RTX_INTERNAL_NUM_TABLE)
               MOV   DPL, A
               MOVX  A, @DPTR                        ; Get the ext. task-num
               MOV   R7, A

               CLR   ?RTX_SUPERVISOR_MODE            ; supervisor_mode := OFF
               DBG_SYS_EXIT
               RTX_ALLOW_INT
               RET

;
;   END OF MODULE
;
	END
